﻿@model List<CMP.ERP.Model.Shipments>
@{
    Layout = null;
}
@Html.Action("Account_Show", "Account");
    <div class="content">
        <div class="right" id="mainFrame">
            <div class="right_cont">
                <div class="header">
                    <div class="header-right">
                        <form method="post">
                            <div id="modal-container-973559" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:1100px; margin-left:-490px;">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                    <h3 id="myModalLabel"></h3>
                                </div>
                                <div class="modal-body">
                                    <table class="table table-hover table-bordered " style="width:960px;text-align:center;margin:0 auto;border:1px solid #428bca;">
                                        <tbody>
                                            <tr>
                                                <td>收货人:</td>
                                                <td><input type="text" name="Shipments_Per" style="width:100px;" /></td>
                                                <td>联系方式:</td>
                                                <td><input type="text" name="Shipments_Phone" style="width:100px;" /></td>
                                            </tr>
                                            <tr>
                                                <td>快递公司:</td>
                                                <td>
                                                    @Html.DropDownList("Express_Company_Id", "--请选择--")
                                                </td>
                                                <td>仓库名称:</td>
                                                <td>
                                                    @Html.DropDownList("WareHose_Id", "--请选择--")
                                                </td>
                                            </tr>
                                            <tr>                                              
                                                <td>地址:</td>
                                                <td>
                                                    <input type="text" name="Shipments_Address" style="width:220px;" />
                                                </td>
                                                <td>购买人:</td>
                                                <td>
                                                    <input type="text" name="purchaser" style="width:220px;" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><input id="Button1" type="button" value="根据商品编码查询" style="margin-top:0;background-color:green;border-radius:2px" onclick="sor()" /></td>
                                                <td><input type="text" name="PorBuy_Cid1" style="width:100px;" /></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                    <table class="table table-hover table-bordered " style="width:960px;text-align:center;margin:0 auto;border:1px solid #428bca;" id="pss">
                                        <thead>
                                            <tr>
                                                <th>请选择</th>
                                                <th>商品编号</th>
                                                <th>商品名称</th>
                                                <th>单据编码</th>
                                                <th>重量</th>
                                                <th>备注</th>
                                                <th>类型</th>
                                                <td>价格</td>
                                                <th>数量</th>
                                                <th>金额</th>
                                            </tr>
                                        </thead>

                                        <tbody></tbody>
                                    </table>

                                </div>
                                <div class="modal-footer">
                                    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button> <button type="button" class="btn btn-default" onclick="mg()"><span class="icon-inbox"></span>保存</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <!-- 顶部 -->
                <div id="middle">
                    <div class="Switch"></div>
                    <script type="text/javascript">
                        $(document).ready(function (e) {
                            $(".Switch").click(function () {
                                $(".left").toggle();     

                            });
                        });
                    </script>

                    <div class="right" id="mainFrame">

                        <div class="right_cont" style="margin-top:10px;">
                            当前位置：
                            <a href="/Home/Index">首页</a>
                            <span class="divider">/</span>
                            订单信息
                            </ul>
                           
                            <div style="width:100%; margin:auto;margin-top:10px">
                                <div>
                                    <form action="/Order/SelShipment" method="get">
                                        <table>
                                            <tr>
                                                <td>下单时间:</td>
                                                <td>从:</td>
                                                <td><input type="text" name="StartTime"  id="Calendar" style="width:147px" /></td>
                                                <td>至:</td>
                                                <td><input type="text" name="End_Time" id="Calendar2" style="width:147px" /></td>
                                                <td>购买人:</td>
                                                <td><input id="Text1" type="text" name="Shipments_Per" style="width:147px" /></td>
                                                <td>联系方式:</td>
                                                <td><input id="Text2" type="text" name="Shipments_Phone" style="width:147px" /></td>
                                                <td><button type="submit" class="btn btn-default" style="margin-bottom:10px"><span class="icon-search"></span>查询 </button></td>
                                                <td><button id="modal-973559" href="#modal-container-973559" role="button" type="button" class="btn btn-default" data-toggle="modal" style="margin-bottom:10px"><span class="icon-plus"></span>购买</button></td>
                                            </tr>
                                        </table>
                                    </form>
                                </div>
                                <div style="margin-top:20px;">
                                    <table class="table  table-hover table-bordered table-striped">
                                        <thead>
                                            <tr>
                                                <td>订单编号</td>
                                                <th>下单时间</th>
                                                <th>购买人</th>
                                                <th>收货人</th>
                                                <th>地址</th>
                                                <th>联系方式</th>
                                                <th>订单状态</th>
                                                <th>快递名称</th>
                                                <th>仓库名称</th>
                                                <th>总金额</th>
                                                <th>操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @foreach (var itme in Model)
                                            {
                                                <tr>
                                                    <td>@itme.Shipments_Id</td>
                                                    <td>@itme.Shipments_data</td>
                                                    <td>@itme.purchaser</td>
                                                    <td>@itme.Shipments_Per</td>
                                                    <td>@itme.Shipments_Address</td>
                                                    <td>@itme.Shipments_Phone</td>
                                                    <td>
                                                        @{
                                                            if (@itme.Shipments_State=="未发货")
                                                            {
                                                                <span style="color:red">@itme.Shipments_State</span>
                                                            }
                                                            else
                                                            {
                                                                <a href="#">@itme.Shipments_State</a>
                                                            }
}
                                                        
                                                    </td>
                                                    <td>@itme.Express_Company_Name</td>
                                                    <td>@itme.WareHose_Name</td>
                                                    <td>@itme.Shipments_SumMoney</td>
                                                    <td>
                                                        @{
                                                if (@itme.Shipments_State == "未发货")
                                                {
                                                    <a href="/Order/DetailsShipmentsShow/@itme.Shipments_Id" style="color:red">审核发货点这里^_^</a>
                                                }
                                                else if (@itme.Shipments_State == "已发货")
                                                {
                                                    <a href="#">已发货</a>
                                                }
                                                else if (@itme.Shipments_State == "已收货")
                                                {
                                                    <span>已收货</span>
                                                }
                                                        }
                                                    </td>
                                                </tr>
                                            }
                                        </tbody>
                                    </table>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>

<script>
    //$(function () {
    //    $.ajax({
    //        type: "get",
    //        url: "/Order/show",
    //        success: function (data) {

    //            $(data).each(function (index, item) {

    //                var pup = "<tr><td><input name='ck' id='Checkbox" + item.Commodity_Id + "' type='checkbox' value='" + item.Commodity_Id + "' name='ck'/></td><td>" + item.Commodity_Id + "</td><td>" + item.Commodity_Name + "</td><td>" + item.Commodity_number + "</td><td>" + item.Commodity_Weight + "</td><td>" + item.Commodity_Remark + "</td><td>" + item.CommodityType_Name + "</td><td name='ck' id='ss" + item.Commodity_Id + "'>" + item.Commodity_Price + "</td><td><input name='pc' id=" + item.Commodity_Id + " type='text' /></td></tr>";
    //                $("#pss tbody").append(pup);
    //            })
    //        }
    //    })
    //})
    //function mg() {
    //    var Shipments_Per = $("[name='Shipments_Per']").val();
    //    var Shipments_Phone = $("[name='Shipments_Phone']").val();
    //    var options1 = $("#Express_Company_Id   option:selected").val();
    //    var option = $("#WareHose_Id option:selected").val();
    //    ($(":checkbox").each(function () {

    //        if ($(this).attr("checked") == "checked") {
    //            var po = $(this).val();
    //        }

    //    }))
    //    var num = "";
    //    var selectval = "";
    //    var price = "";
    //    var list = $("[name='ck']:checked");
    //    $(list).each(function (index, item) {
    //        ss = $(item).val();
    //        num += $("#" + ss + "").val() + ",";
    //        price += $("#ss" + ss + "").html() + ",";
    //        if (selectval.length > 0) {
    //            selectval += ",";
    //        }
    //        selectval += $(item).val();
    //    })
    //    num = num.substr(0, num.length - 1);
    //    price = price.substr(0, price.length - 1);
    //    $.ajax({
    //        type: "post",
    //        url: "/Order/add",
    //        data: {
    //            Shipments_Per: Shipments_Per,
    //            Shipments_Phone: Shipments_Phone,
    //            ShipmentMate_num: num,
    //            Express_Company_Id: options1,
    //            WareHose_Id: option,
    //            Commodity_Id: selectval,
    //            Commodity_price: price
    //        },
    //        success: function (data) {
    //            if (data == "True") {
    //                alert("Ok");
    //                location.href = "/Order/Order_show";
    //            }
    //            else {
    //                alert("No");
    //            }
    //        },
    //        error: function () {

    //            alert("失败,粗错了");
    //        }
    //    })
    //}
</script>
<script>
    function mg() {
        var Shipments_Per = $("[name='Shipments_Per']").val();
        var Shipments_Phone = $("[name='Shipments_Phone']").val();
        var options1 = $("#Express_Company_Id   option:selected").val();
        var option = $("#WareHose_Id option:selected").val();
        var Shipments_Address = $("[name='Shipments_Address']").val();
        var purchaser = $("[name='purchaser']").val();
        ($(":checkbox").each(function () {

            if ($(this).attr("checked") == "checked") {
                var po = $(this).val();
            }

        }))
        var num = "";
        var selectval = "";
        var price = "";
        var list = $("[name='ck']:checked");
        $(list).each(function (index, item) {
            ss = $(item).val();
            num += $("#num" + ss + "").val() + ",";
            price += $("#ss" + ss + "").html() + ",";
            if (selectval.length > 0) {
                selectval += ",";
            }
            selectval += $(item).val();
        })
        num = num.substr(0, num.length - 1);
        price = price.substr(0, price.length - 1);
        $.ajax({
            type: "post",
            url: "/Order/add",
            data: {
                Shipments_Per: Shipments_Per,
                Shipments_Phone: Shipments_Phone,
                ShipmentMate_num: num,
                Express_Company_Id: options1,
                Shipments_Address: Shipments_Address,
                purchaser:purchaser,
                WareHose_Id: option,
                Commodity_Id: selectval,
                Commodity_price: price
            },
            success: function (data) {
                if (data == "True") {
                    alert("Ok");
                    location.href = "/Order/Order_show";
                }
                else {
                    alert("No");
                }
            },
            error: function () {

                alert("失败,粗错了");
            }
        })
    }
    function sor() {
        var ss = $("[name='PorBuy_Cid1']").val();
        $.ajax({
            type: "get",
            url: "/Procurement/Search",
            data: {
                num: ss
            },
            success: function (data) {
                for (var i in data) {
                    var pup = "<tr id='" + data[i].Commodity_Id + "'><td><input name='ck' id='Checkbox" + data[i].Commodity_Id + "' type='checkbox' value='" + data[i].Commodity_Id + "' name='ck'/></td><td>" + data[i].Commodity_Id + "</td><td>" + data[i].Commodity_Name + "</td><td>" + data[i].Commodity_number + "</td><td>" + data[i].Commodity_Weight + "</td><td>" + data[i].Commodity_Remark + "</td><td>" + data[i].CommodityType_Name + "</td><td name='ck' id='ss" + data[i].Commodity_Id + "'>" + data[i].Commodity_Price + "</td><td><input name='pc' id='num" + data[i].Commodity_Id + "' type='text' onchange='scrp(" + data[i].Commodity_Id + ")'/></td><td><span id='SumMoney" + data[i].Commodity_Id + "' name='SumMoney'>0</span>元</td></tr>";
                    if ($("#" + data[i].Commodity_Id + "").length > 0)
                    {
                        alert("已存在该商品!");
                    }
                    else
                    {
                        $("#pss tbody").append(pup);
                    }
                   
                }
                  
                
            }
        })
    }
    function scrp(id) {
        var num = $("#num" + id + "").val();
        var price = $("#ss" + id + "").html();
        var sum = num * price;
        $("#SumMoney" + id + "").html(sum);

    }
    //function sor1() {
    //    var ss = $("[name='PorBuy_Cid2']").val();
    //    $.ajax({
    //        type: "get",
    //        url: "/Procurement/SearchByName",
    //        data: {
    //            name: ss
    //        },
    //        success: function (data) {
               
    //            $(data).each(function (index, item) {
    //                var pup = "<tr id='" + item.Commodity_Id + "'><td><input id='Checkbox" + item.Commodity_Id + "' type='checkbox' value='" + item.Commodity_Id + "' name='ck'/></td><td>" + item.Commodity_Id + "</td><td>" + item.Commodity_Name + "</td><td>" + item.Commodity_number + "</td><td>" + item.Commodity_Weight + "</td><td>" + item.Commodity_Remark + "</td><td>" + item.CommodityType_Name + "</td><td>" + item.Commodity_Price + "<td><input name='pc' id=" + item.Commodity_Id + " type='text' /></td></tr>";
    //                if ($("#" + item.Commodity_Id + "").length > 0)
    //                {
    //                    alert("已存在该商品!");
    //                }
    //                else
    //                {
    //                    $("#pss tbody").html(pup);
    //                }
                   
    //            })
    //        }
    //    })
    //}
</script>